package com.SRMS.service;

import com.SRMS.dao.AdministratorDAO;
import com.SRMS.domain.Administrator;

/**
 * @author Albert
 * @version 1.0
 * @date 2023/12/19-10:09
 * @describe 管理员服务类
 */
public class AdministratorService {
    private Administrator administrator = null;
    private AdministratorDAO administratorDao = new AdministratorDAO();
    private StudentManageService studentManageService = new StudentManageService();
    private StudyRoomManageService studyRoomManageService = new StudyRoomManageService();
    private RightManageService rightManageService = new RightManageService();

    public StudentManageService getStudentManageService() {
        return studentManageService;
    }

    public StudyRoomManageService getStudyRoomManageService() {
        return studyRoomManageService;
    }

    public RightManageService getRightManageService() {
        return rightManageService;
    }

    /**
     * 获取登录成功的管理员对象
     * @return 管理员对象
     */
    public Administrator getAdministrator() {
        return administrator;
    }

    /**
     *  根据工号和密码查询管理员
     * @param administratorId 工号
     * @param password 密码
     * @return 返回管理员对象
     */
    public Administrator getAdministratorByIdAndPwd(String administratorId, String password){
        administrator = administratorDao.querySingle("SELECT * FROM administrator WHERE administratorId=? AND password=MD5(?)", Administrator.class, administratorId, password);
        return administrator;
    }
}
